package com.cy.milktea.utils;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.Servlet;
import javax.servlet.http.HttpServletRequest;

/**
 * 获取当前请求对象的工具类
 */
public class ServletUtils {

    public static ServletRequestAttributes getServletRequestAttributes() {
        return (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();

    }

    public static HttpServletRequest getHttpRequest() {
        return (HttpServletRequest) getServletRequestAttributes().getRequest();
    }
}
